﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="HistoryPosition.aspx.cs" Inherits="Student_Report_HistoryPosition" %>

<%@ Register Src="../../Custom/ucEduSubject.ascx" TagName="ucEduSubject" TagPrefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>学生的考试排名查询</title>
    <link href="../../Common/css/main.css" rel="stylesheet" type="text/css" /> 
    <script type="text/javascript" src="../../Common/Js/jquery.js"></script>
    <script type="text/javascript" src="../../Common/Js/common.js"></script>
    <script type="text/javascript" src="../../Common/Js/msg.js"></script>
    <script type="text/javascript" src="../../Common/Js/xTree/dhtmlxcommon.js"></script>
    <script type="text/javascript" src="../../Common/Js/xTree/dhtmlxtree.js"></script>
    <script language="javascript">
var exams = new Array();
    var schoolYear = Array();
    function InitSelect(selectId,year)
    {
        var sel = document.getElementById(selectId);
        if(sel!=null)
        {
            for(i=0;i<schoolYear.length;i++)
            {
                var oOption = document.createElement("OPTION");
                oOption.text = schoolYear[i];
                oOption.value = schoolYear[i];
                if(year == i)
                {
                    oOption.selected = true;
                }
                else
                {
                    oOption.selected = false;
                }
                sel.add(oOption);
            }
        }
    }
    function startChange()
    {
        document.getElementById("txtStart").value=event.srcElement.value;
    }
    function endChange()
    {
        document.getElementById("txtEnd").value=event.srcElement.value;
    }
    function ShowView()
    {
        var s = document.getElementById("txtStart").value;
        var e = document.getElementById("txtEnd").value;
        if(document.getElementById("subjSelect").selectedIndex>-1)
        {
            document.getElementById("txtSubjID").value = document.getElementById("subjSelect").options[document.getElementById("subjSelect").selectedIndex].value;
        }
        
        var schoolids ="   -1";var educationids ="  -1";
        var educationGrades = " -1";
        for(i=0;i<exams.length;i++)
        {
            if(exams[i].schoolYear<=e && exams[i].schoolYear>=s)
            {
                if(exams[i].examType==1)
                {
                    educationids += ","+exams[i].examID;
                    educationGrades+=","+exams[i].grade;
                }
                else
                {
                    schoolids += ","+exams[i].examID ;
                }
            }
        }
        document.getElementById("txteduIDS").value = educationids;
        document.getElementById("txteduGrades").value=educationGrades;
        document.getElementById("txtschoolIDS").value=schoolids;
        document.getElementById("btnBind").click();
    }
    function closePopForm(name)
    {
        document.getElementById("parfrm").src = "";
        return ClosePopForm(name);
    }
    function showHistory()
    {
         document.getElementById("parfrm").src = "HistoryChart.aspx";
         ShowPopForm("upInputPop", "upInputPopTitle","历史成绩趋势")   ; 
    }
    var currObj = null;
    function SetHightLight(obj)
    {
        if(obj!=null)
        {
            if(currObj!=null)
            {
                currObj.style.backgroundColor = "#ffffff";
            }
            obj.style.backgroundColor = "#fffccf";
            currObj = obj;
        }
    }
    </script> 

    <link href="../../Common/css/main.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div class="mainWarp">
        <div class="pageBoby"  style="padding-top:5px;padding-left:5px;">
        开始学年：<select id="startYear" onchange="startChange()">
            </select> &nbsp;&nbsp;结束学年:
            <select id="endYear" onchange="endChange()">
            </select>
            
        考试科目：<select id="subjSelect">
            </select>
        <input id="Button1" type="button" value="查询" class="commonBut" onclick="ShowView()" /> <input id="Button2" type="button" value="查看趋势图" class="commonBut" onclick="showHistory()" />
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
                    </asp:ScriptManager>
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                    <h4><asp:Label ID="Label1" runat="server" Text=""></asp:Label></h4>
                        <asp:Repeater ID="Repeater1" runat="server">
                            <HeaderTemplate>
                                <table id="settingTable" border="0" cellpadding="0" cellspacing="1"  style="width:600px;" class="useList">
                                <tr>
                                    <th style='text-align:left;padding-left: 5px;'>考试名</th>
                                    <th style='text-align:left;padding-left: 5px;'>考试时间</th>
                                    <th style='text-align:right;padding-right: 5px;'>班级名次</th>
                                    <th style='text-align:right;padding-right: 5px;'>年级名次</th>
                                    <% if (Common.CurrentVersion != EduVersion.School) { %>
                                    <th style='text-align:right;padding-right: 5px;'>统考排名</th>
                                  <% }%>
                                    
                                </tr>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <tr onclick='SetHightLight(this);'>
                                <%# GetExaminfo((int)Eval("ExamType"), (int)Eval("ExamID"), (int)Eval("Grade"))%>
                                </tr>
                            </ItemTemplate>
                            <FooterTemplate>
                                </table>
                            </FooterTemplate>
                        </asp:Repeater>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="btnBind" EventName="Click" />
                    </Triggers>
                </asp:UpdatePanel>
                <div style="display: none;">
                  <asp:Button ID="btnBind" runat="server" OnClick="btnBind_Click" Text="btnBind" />
                    <asp:TextBox ID="txtStart" runat="server">0</asp:TextBox>
                    <asp:TextBox ID="txtEnd" runat="server">0</asp:TextBox>
                    <asp:TextBox ID="txteduIDS" runat="server"></asp:TextBox>
                    <asp:TextBox ID="txteduGrades" runat="server"></asp:TextBox>
                    <asp:TextBox ID="txtschoolIDS" runat="server"></asp:TextBox>
                    <asp:TextBox ID="txtSubjID" runat="server"></asp:TextBox>
                </div>
        </div>
    </div>
    
    <div id="upInputPop" class="layoutWarp" style="display: none; width:740px;height:395px;">
         <div class="title" >
	        <span id="upInputPopTitle"></span>
            <a title="关闭" onclick="closePopForm('upInputPop')">关闭</a>
          </div>
        <iframe src="" name="ifram" id="parfrm" style="height: 85%;width: 95%;overflow:hidden;" frameborder="0"   ></iframe>
    </div>
    </form>
</body>
</html>

<script language="javascript">
 <%
        int index =0;
        foreach (StuExam se in stuExam)
        {
            Response.Write("exams[" + index + "]={examType:" + se.examType + ",examID:"+se.examID+",examName:'" + se.examName + "',schoolYear:" + se.schoolYear + ",grade:"+se.grade+",ClassType:"+se.classType+"};");
            index++;
        }     
        index =0;
        foreach(int y in schoolYear)
        {

            Response.Write("schoolYear["+index+"]="+y+";");
            index++;
        }
        if(schoolYear.Count>0)
        {
            Response.Write("InitSelect('startYear',"+schoolYear[0]+");");
            Response.Write("InitSelect('endYear',"+schoolYear[0]+");");
            Response.Write("document.getElementById('txtStart').value="+schoolYear[0]+";");
            Response.Write("document.getElementById('txtEnd').value="+schoolYear[0]+";");
        }
        System.Collections.Generic.List<int> getin = new System.Collections.Generic.List<int>();
        Response.Write("var oOption;");
        if(causeinfo!=null)
        {
            foreach(Meqs.Entity.GlobalCauseInfo ese in causeinfo)
            {
                if(!getin.Contains(ese.RID))
                {
                    Response.Write("oOption = document.createElement(\"OPTION\");");
                    string t = this.Server.HtmlDecode(ese.CauseName);
                    t = t.Replace("\\", "\\\\");
                    t = t.Replace("'", "\\'");
                    t = t.Replace("<", "\\<");
                    t = t.Replace(">", "\\>");
                    Response.Write("oOption.text ='" + t + "';");
                    Response.Write("oOption.value ='" + ese.RID + "';");
                    Response.Write("oOption.selected = false;");
                    Response.Write("document.getElementById('subjSelect').add(oOption);");
                    getin.Add(ese.RID);
                }
            }     
            if(getin.Count>0)
            {
                Response.Write("oOption = document.createElement(\"OPTION\");");
                Response.Write("oOption.text ='总分';");
                Response.Write("oOption.value ='0';");
                Response.Write("oOption.selected = true;");
                Response.Write("document.getElementById('subjSelect').add(oOption);");
//                Response.Write("document.getElementById('subjSelect').selectedIndex=0;");
                Response.Write("ShowView();");
                
            }      
        }

 %>
//        if(document.getElementById("selTerm").selectedIndex>-1)
//        {
//            document.getElementById("txtSubjID").value = document.getElementById("selTerm").options[document.getElementById("selTerm").selectedIndex].value;
//            ShowView();
//        }
 </script>